package com.technicalkeeda.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.technicalkeeda.bean.Login;

public class LoginValidator implements Validator {

	public boolean supports(Class aClass) {
		return Login.class.equals(aClass);
	}

	public void validate(Object obj, Errors errors) {
		Login login = (Login) obj;

		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userName",
				"username.required", "Required field");

		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userPassword",
				"userpassword.required", "Required field");
	}

}
